﻿//********************************************************************************//
//创建日期：<创建日期，2016-04-13>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：支票现金付委查看
//********************************************************************************//
using System;
using BLL;
using BLL.Access;
using System.Data;
using Web.Class;

namespace Web.Pages.YongShui
{
    public partial class ZhiPiaoXJFW_CK : BasePage
    {
        #region 属性

        /// <summary>
        /// 记录操作人站点
        /// </summary>
        private string zhandianbh
        {
            get
            {
                return Convert.ToString(ViewState["zhandianbh"]);
            }
            set
            {
                ViewState["zhandianbh"] = value;
            }
        }

        /// <summary>
        /// 记录查询结果集
        /// </summary>
        private DataTable dtSource
        {
            get
            {
                return ViewState["dtSource"] as DataTable;
            }
            set
            {
                ViewState["dtSource"] = value;
            }
        }

        /// <summary>
        /// 记录查询结果集2
        /// </summary>
        private DataTable dtSource2
        {
            get
            {
                return ViewState["dtSource2"] as DataTable;
            }
            set
            {
                ViewState["dtSource2"] = value;
            }
        }

        #endregion

        #region 变量

        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _spHelper = new SpHelper();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {            
            //第一次页面加载
            if (!IsPostBack)
            {
                InitailControl();                
            }
            LoadDataHZ(true);
            LoadDataMX(true);
        }

        #endregion

        #region 方法

        /// <summary>
        /// 加载控件
        /// </summary>
        private void InitailControl()
        { 
            this.txtZWYM.Text=this.Request["ym"];            
            //加载条件查询处的管理块
            DataTable dtConGLK = BusinessTool.GetTextAndValue(
                "YS_JX_GUANLIK", "S_GUANLIKMC", "S_GUANLIKH",null, "I_JLZT=0"
                ).Tables[0];
            DataRow row = dtConGLK.NewRow();
            row[0] = "全部";
            dtConGLK.Rows.InsertAt(row,0);
            PageTools.BindComboBox(
                this.cmbconGuanlik, dtConGLK
            );
        }

        /// <summary>
        /// 查询数据
        /// </summary>
        private void LoadDataHZ(bool reGet)
        {
            if (reGet)
            {
                this.dtSource = SearchSpHelper.P_YSSF_GETXJZPFWSFTJORMX(this.cmbconGuanlik.SelectedIndex==0?null:this.cmbconGuanlik.Value.ToString(),int.Parse(this.txtZWYM.Text),0).Tables[0];
            }
            if (this.dtSource != null)
            {
                this.gvList1.DataSource = this.dtSource;
                this.gvList1.DataBind();
            }
        }

        /// <summary>
        /// 查询数据
        /// </summary>
        private void LoadDataMX(bool reGet)
        {
            if (reGet)
            {
                this.dtSource2 = SearchSpHelper.P_YSSF_GETXJZPFWSFTJORMX(this.cmbconGuanlik.SelectedIndex == 0 ? null : this.cmbconGuanlik.Value.ToString(), int.Parse(this.txtZWYM.Text), 1).Tables[0];
            }
            if (this.dtSource2 != null)
            {
                //this.dtSource2.Rows[this.dtSource2.Rows.Count - 1]["D_SHOUFEIRQ"]="";
                this.gvList2.DataSource = this.dtSource2;
                this.gvList2.DataBind();
            }
        }

        #endregion

        #region 事件

        protected void gvList1_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            LoadDataHZ(true);
        }

        protected void gvList2_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            LoadDataMX(true);
        }

        /// <summary>
        /// 列表二定位
        /// </summary>
        protected void btnConGoto_Click(object sender, EventArgs e)
        {
            if (this.txtconYonghuh.Text.Trim() != "")
            {
                int id = PageTools.FocusOpreateRecord(this.dtSource2, this.gvList2, "S_YONGHUH", this.txtconYonghuh.Text, true);
                if (id == -1)
                {
                    PageTools.AlertMsg(this, "当前数据中没有你要找的数据,请检查你输入的条件是否正确。");
                }
            }
        }
                
        #endregion

       
       
    }
}